// 游戏容器
const mapContainer = document.querySelector(".game-container");

// 行数
let tr = 30;
// 列数
let td = 30;

// 蛇身体宽度
const snakeBody = 20;
// 方向信息
const directionInfo = {
  top: {
    x: 0,
    y: -1,
    flag: "top",
    transform: "rotate(-90deg)",
  },
  bottom: {
    x: 0,
    y: 1,
    flag: "bottom",
    transform: "rotate(90deg)",
  },
  left: {
    x: -1,
    y: 0,
    flag: "left",
    transform: "rotate(180deg)",
  },
  right: {
    x: 1,
    y: 0,
    flag: "right",
    transform: "rotate(0deg)",
  },
};
// 蛇信息
let snakeInfo = {
  // 移动方向
  direction: directionInfo.right,
  // 蛇体
  snakeBody: [
    { x: 0, y: 0, domComponent: "", flag: "body" },
    { x: 1, y: 0, domComponent: "", flag: "body" },
    { x: 2, y: 0, domComponent: "", flag: "body" },
    { x: 3, y: 0, domComponent: "", flag: "head" },
  ],
};

// 食物
let food = {
  x: 0,
  y: 0,
  domComponent: "",
};

// 定时器
let timer = null;

// 移动速度(ms)
const moveTime = 200;

// 分数
let score = 0;